package br.ucb.ucblive.managedbean;

import java.io.Serializable;
import java.util.Locale;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;

import br.ucb.ucblive.recursos.Functions;

@ManagedBean (name="localeManagedBean")
@SessionScoped
public class LocaleManagedBean implements Serializable {
	 private static final long serialVersionUID = 4420995111496888033L;  
	 private Locale currentLocale;
	 
	 public LocaleManagedBean() {
		setCurrentLocale(new Locale("pt", "BR"));
	}
	
	 public void englishLocale() {    
		 UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
	     currentLocale =Locale.US;    
	     viewRoot.setLocale(currentLocale);    
	 }    
	      
	 public void portugueseLocale() {    
	    UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();    
	    currentLocale = new Locale("pt", "BR");    
	    viewRoot.setLocale(currentLocale); 
	 }    
	      
	 public Locale getCurrentLocale() {   
	     return currentLocale;    
	 }

	public void setCurrentLocale(Locale currentLocale) {
		this.currentLocale = currentLocale;
	}    
}
